package com.summer.springboot.jpa.repository;

import com.summer.springboot.jpa.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

@Repository
public interface UserRepository extends JpaRepository<User, Long> {

    @Modifying
    @Transactional(timeout = 1000)
    @Query(value = "update User set name = ?2 where id = ?1")
    int updateByUsername(Long userId, String username);

}
